<template>
	<view class="c-empty" :style="{ top: `${offsetTop}rpx ` }">
		<image class="icon" :src="comptIcon" mode=""></image>
		<view class="info">
			<slot>
				<view class="title">
					{{ title }}
				</view>
				<view class="desc">
					{{ desc }}
				</view>
			</slot>
		</view>
	</view>
</template>

<script setup>
	import { reactive, computed } from 'vue';

	const props = defineProps({
		title: {
			type: String,
			default: '暂无数据'
		},
		desc: String,
		offsetTop: {
			type: [Number, String],
			default: 0
		},
		iconName: {
			type: String,
			default: 'data'
		},
		image: String
	});

	const state = reactive({
		iconList: {
			cart: '/static/images/empty/cart.png',
			data: '/static/images/empty/data.png',
			wifi: '/static/images/empty/wifi.png',
			notice: '/static/images/empty/notice.png',
			history: '/static/images/empty/history.png',
			evaluate: '/static/images/empty/evaluate.png',
			coupon: '/static/images/empty/coupon.png',
			auth: '/static/images/empty/auth.png',
			404: '/static/images/empty/404.png',
			address: '/static/images/empty/address.png',
			news: '/static/images/empty/news.png',
			notice2: '/static/images/empty/notice2.png',
			order: '/static/images/empty/order.png',
			search: '/static/images/empty/search.png'
		}
	});

	const comptIcon = computed(() => {
		if (props.image) {
			return props.image;
		}
		return state.iconList[props.iconName];
	});
</script>

<style lang="scss">
	.c-empty {
		@include f-center($direction: column);
		padding: $margin-24;
		position: relative;
		top: 0;
		.icon {
			width: 300rpx;
			height: 300rpx;
			.info {
				@include f-center(column);
				margin-top: $margin-24;
				.title {
					color: $main-color;
				}
				.desc {
					font-size: $font-24;
					color: $tips-color;
				}
			}
		}
	}
</style>
